package edu.mapi.ir.state;

import java.awt.geom.Rectangle2D;

/**
 * @author ZP
 */
public class EstimatedCell {

	private double x, y;
	private Rectangle2D shape;
	
	// start with a value different from 0...
	private int countSightings = 2;
	private double wallProbability = 0.5;
	
	public EstimatedCell(double x, double y) {
		this.x = x;
		this.y = y;
		this.shape = new Rectangle2D.Double(x, y, 1, 1);
	}
	
	public void addSighting(boolean present) {
		int seen = present? 1 : 0;
		countSightings++;
		wallProbability = (wallProbability + seen) / countSightings;		
	}
	
	
	public void addSighting(double interceptedArea) {
		
		interceptedArea = Math.min(interceptedArea, 1);
		interceptedArea = Math.max(interceptedArea, 0);
		
		countSightings++;
		wallProbability = (wallProbability + interceptedArea) / countSightings;		
	}
	

	public double getX() {
		return x;
	}

	public void setX(double x) {
		this.x = x;
	}

	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
	}

	public Rectangle2D getShape() {
		return shape;
	}

	public void setShape(Rectangle2D shape) {
		this.shape = shape;
	}

	public double getWallProbability() {
		return wallProbability;
	}

	public void setWallProbability(double wallProbability) {
		this.wallProbability = wallProbability;
	}
	
}
